//
//  XZSigninQRcodeCell.m
//  Teecloud
//
//  Created by PC on 2018/11/7.
//  Copyright © 2018年 小志. All rights reserved.
//

#import "XZSigninQRcodeCell.h"

@interface XZSigninQRcodeCell ()
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;

@property (weak, nonatomic) IBOutlet UILabel *timeLabel;

@property (weak, nonatomic) IBOutlet UILabel *numCountLabel;
/*删除 复制 编辑 二维码按钮*/
@property (weak, nonatomic) IBOutlet UIButton *deleteButton;
@property (weak, nonatomic) IBOutlet UIButton *QRcodeCopyButton;
@property (weak, nonatomic) IBOutlet UIButton *editButton;
@property (weak, nonatomic) IBOutlet UIButton *QRcodeButton;
//按钮view的宽度
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *buttonViewWidth;
/*复制按钮右边距离二维码的间距*/
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *btnRight;

@end

@implementation XZSigninQRcodeCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setModel:(XZQRcode *)model{
    _model = model;
    self.nameLabel.text = model.Name;
    self.timeLabel.text = model.StartEndTimeName;
    
    if (model.IsNeedSignIn) {
        self.numCountLabel.text = [NSString stringWithFormat:@"共%@人,签到%@人",model.Count,model.SignCount];
    }
    if (model.IsNeedSignOut) {
        self.numCountLabel.text = [NSString stringWithFormat:@"共%@人,签退%@人",model.Count,model.OutCount];
    }
    if (model.IsNeedSignOut && model.IsNeedSignIn) {
        self.numCountLabel.text = [NSString stringWithFormat:@"共%@人,签到%@人,签退%@人",model.Count,model.SignCount,model.OutCount];
    }
    
    //IsCanEdit=false时隐藏 删除 编辑按钮
    if (!model.IsCanEdit) {
        self.deleteButton.hidden = true;
        self.editButton.hidden= true;
        self.buttonViewWidth.constant = 98;
        self.btnRight.constant = 5.f;
    }else{
        self.deleteButton.hidden = false;
        self.editButton.hidden= false;
        self.buttonViewWidth.constant = 183;
        self.btnRight.constant = 48.f;
    }
}

//删除
- (IBAction)deleteButtonAction:(UIButton *)sender {
    if (self.QRCodeBlock) {
        self.QRCodeBlock(@"DELETE");
    }
}
//复制
- (IBAction)copyButtonAction:(UIButton *)sender {
    if (self.QRCodeBlock) {
        self.QRCodeBlock(@"COPY");
    }
}

//编辑
- (IBAction)editButtonAction:(UIButton *)sender {
    if (self.QRCodeBlock) {
        self.QRCodeBlock(@"EDIT");
    }
}
//二维码
- (IBAction)qrcodeButtonAction:(UIButton *)sender {
    if (self.QRCodeBlock) {
        self.QRCodeBlock(@"QRCODE");
    }
}


@end
